<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header">
</head>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>预备党员备案呈交</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="form_basic.html#">选项1</a>
                                </li>
                                <li><a href="form_basic.html#">选项2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="recordsForm">
                        
                        <div class="form-group">
                                <label class="col-sm-3 control-label">选择预审记录：</label>
                                <div class="col-sm-8">
                                    <div class="input-group">
                                    	<input type="text" hidden="hidden" id="prepareEvolveId" name="prepareEvolveId">
		                                <input type="text" class="form-control" name="conferenceq" id="conferenceq">
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                            		</div>
                                </div>
                            </div>
                        
                            <div class="form-group">
                                <label class="col-sm-3 control-label">选择会议记录：</label>
                                <div class="col-sm-8">
                                    <div class="input-group">
                                    	<input type="text" hidden="hidden" id="conferenceIdSecond" name="conferenceIdSecond">
		                                <input type="text" class="form-control" name="conferences" id="conferences">
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                            		</div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">会议时间：</label>
                                <div class="col-sm-8">
                                    <input id="date" readonly placeholder="请选择会议记录" name="date" class="form-control valid" type="text" aria-required="true" aria-invalid="false">
                                	<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 选择会议后自动填充</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">备案请示名单：</label>
                                <div class="col-sm-8">
                                	<input id="prepareList" name="prepareList" hidden="hidden" type="text">
                                    <input id="successLists" readonly style="color: green" placeholder="请选择会议记录" name="successLists" class="form-control required" type="text">
                                	<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 选择会议后自动填充</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">预备党员名册：</label>
                                <div class="col-sm-8">
                                    <input id="file" aria-required="true" name="file" class="form-control required" type="file">
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请手动上传文件</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-5">
                                    <a class="btn btn-default" onclick="$.modal.close()">取消</a>&nbsp;&nbsp;
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <div th:include="include::footer"></div>
	<!-- 甜甜的弹出层 -->
 	<script src="https://cdn.bootcss.com/limonte-sweetalert2/7.21.1/sweetalert2.all.js"></script>
	<script type="text/javascript">
	//初始化文件选择框
    	$( 'input[type="file"]' ).prettyFile();
        var prefix = "/module/prepareEvolve"
		//表单验证
        $().ready(function () {
            $("#commentForm").validate();
            var icon = "<i class='fa fa-times-circle'></i> ";
            $("#recordsForm").validate({
                rules: {
                	conferenceq: "required",
                	conferences: "required",
                	date: "required",
                	prepareList: "required",
                	file: "required"
                },
                messages: {
                	conferenceq: "请选择预审会议",
                    conferences: icon + "请选择会议",
                    date: icon + "请选择会议",
                	prepareList: icon + "请选择会议",
                },
    			submitHandler: function(form) {
    				var forms = new FormData(document.getElementById('recordsForm'));
					$.modal.loading("正在处理中，请稍后...");
					$.ajax({
						url : '/module/prepareEvolve/save',
						type : "post",
						dataType : "json",
						data : forms,
						processData: false,
						contentType: false,
						success : function(result) {
							$.operate.saveSuccess(result)
						}
					});
				}
            });
        });
        
        //初始化会议下拉选择框
	    var testBsSuggest = $("#conferences").bsSuggest({
            url: "/module/conference/getConferenceList/?conferenceType=4",
            effectiveFields: ["conferenceName", "时间", "备注"], //有效显示于列表中的字段，非有效字段都会过滤，默认全部，对自定义getData方法无效
            idField: "conferenceId",		//每组数据的哪个字段作为 data-id，优先级高于 indexId 设置（推荐）
            keyField: "conferenceName",		//每组数据的第几个数据，作为input输入框的内容
            showBtn: false,                  //是否显示下拉按钮
		    allowNoKeyword: true,           //是否允许无关键字时请求数据
		    multiWord: false,               //以分隔符号分割的多关键字支持(开了这个警告色功能可能失效)
		    separator: ",",                 //多关键字支持时的分隔符，默认为半角逗号
		    inputWarnColor: "rgba(255,0,0,.1)", //输入框内容不是下拉列表选择时的警告色
		    //effectiveFieldsAlias: ["会议名称", "时间", "类型"],    //有效字段的别名对象，用于 header 的显示
		    effectiveFieldsAlias: {conferenceName:"会议名称"},//尝试多个别名失败
		    //effectiveFieldsAlias: {conferenceDate:"时间"},
		    showHeader: true, //显示 header 
        }).on('onDataRequestSuccess', function (e, result) {
            //console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword) {
            //console.log('onSetSelectValue: ', keyword);
            $.ajax({
    			url: '/module/conference/selectConferenceById?type=tt',
    			data: {"id": keyword.id},
    			dataType: 'json',
    			checkFile: true,
    			success: function(value){
    				console.log(value);
    				$("#conferenceIdSecond").val(keyword.id);
    				$("#date").val(value.conferenceTime);
    				$("#prepareList").val(value.successList);
    				$("#successLists").val(value.remark);
    			},
    			error: function(value){
    				swal(
    					"请求失败",
    					"请联系网站管理员",
    					"error"
    				);
    			}
            });
        }).on('onUnsetSelectValue', function (e) {
        	$("#conferenceIdSecond").val('');
            $("#date").val('');
    		$("#prepareList").val('');
    		$("#successLists").val('');
        });
        
        //初始化预审记录下拉选择框
	    var testBsSuggest = $("#conferenceq").bsSuggest({
            url: "/module/prepareEvolve/selectPassExamine",
            effectiveFields: ["conferenceName", "时间", "备注"], //有效显示于列表中的字段，非有效字段都会过滤，默认全部，对自定义getData方法无效
            idField: "prepareEvolveId",		//每组数据的哪个字段作为 data-id，优先级高于 indexId 设置（推荐）
            keyField: "conferenceName",		//每组数据的第几个数据，作为input输入框的内容
            showBtn: false,                  //是否显示下拉按钮
		    allowNoKeyword: true,           //是否允许无关键字时请求数据
		    multiWord: false,               //以分隔符号分割的多关键字支持(开了这个警告色功能可能失效)
		    separator: ",",                 //多关键字支持时的分隔符，默认为半角逗号
		    inputWarnColor: "rgba(255,0,0,.1)", //输入框内容不是下拉列表选择时的警告色
		    //effectiveFieldsAlias: ["会议名称", "时间", "类型"],    //有效字段的别名对象，用于 header 的显示
		    effectiveFieldsAlias: {conferenceName:"预审会议名称"},//尝试多个别名失败
		    //effectiveFieldsAlias: {conferenceDate:"时间"},
		    showHeader: true, //显示 header 
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword) {
			$("#prepareEvolveId").val(keyword.id);
        }).on('onUnsetSelectValue', function (e) {
        	$("#prepareEvolveId").val('');
        });
	
	</script>
</body>
</html>
